package com.itwill.ecom.admin;

import java.util.ArrayList;
import java.util.List;

import javax.servlet.http.HttpSession;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;

import com.itwill.ecom.board.BoardService;
import com.itwill.ecom.boardType.BoardTypeBeans;
import com.itwill.ecom.boardType.BoardTypeService;
import com.itwill.ecom.category.CategoryBeans;
import com.itwill.ecom.category.CategoryService;
import com.itwill.ecom.company.CompanyBeans;
import com.itwill.ecom.company.CompanyService;
import com.itwill.ecom.member.MemberBeans;
import com.itwill.ecom.member.MemberService;
import com.itwill.ecom.product.ProductService;

@Controller
@RequestMapping("/admin")
public class AdminController {	
	
	@Autowired MemberService memberService;
	@Autowired CategoryService categoryService;
	@Autowired CompanyService companyService;
	@Autowired ProductService productservice;
	@Autowired BoardTypeService boardTypeService;

	public AdminController() {
		System.out.println("△AdminController 생성자△");
	}
	
	@RequestMapping("/adminmain")
	public String adminMain(){
		
		System.out.println("△adminmain요청△");
		
		return "admin/admin_main";
	}
	
	@RequestMapping("/adminleft")
	public String adminLeft(){
		
		System.out.println("△adminleft요청△");
		
		return "admin/admin_left";
	}
	
	
	
	
	/*********** MEMBER ************/
	
	/** AdminMember **/
	@RequestMapping("/adminmember") //선택된 페이지(selectPageNo)값과 함께 Count가 계산하게 된다.
	public String adminMember(HttpSession session){
		
		/****** 관리자아이디(grade=0) 검사 아니면 main으로 가게됨 ******/ 
		try{
			String sid = String.valueOf(session.getAttribute("sid"));//마스터아이디인지 검사하려고
			MemberBeans memberBeans = memberService.getMemberById(sid);
			if(memberBeans.getMember_grade()!=0){
				return "redirect:/";
			}
		}
		catch(Exception e){
			System.out.println("adminmember Admin아이디 검색중 Exception");
			return null;
		}
		/*******************************************************/
		
		System.out.println("△adminmember요청△");
	
		return "admin/admin_member";
	}
		
	/** 관리자 - 멤버페이지에서 멤버리스트 콜백 **/
	@RequestMapping("/getajaxadminmember")
	public @ResponseBody AdminListBeans getAjaxAdminMember(@RequestParam("selectPageNo") int selectPageNo){
		
		System.out.println("△getajaxadminmember요청△");
		
		
		try{

			List<MemberBeans> realMemberBeansList = memberService.getMemberList(); //전체멤버리스트

			/** 페이지 설정(한페이지에 보여질행수, 한페이지에 보여질페이지수 및 선택된 페이지) **/
			final int rowCount = 9; //보여질행수
			final int pagingCount = 10; //보여질페이지수
			AdminPageConfigBeans adminPageConfigBeans = new AdminPageConfigBeans(rowCount, pagingCount, selectPageNo);
			AdminListBeans adminListBeans = AdminPageCounter.instance().findList(adminPageConfigBeans, realMemberBeansList.size()); //아직 뿌려질리스트 넣지 않은 상태
			
			/** 실제리스트에서 뽑아서 뿌려질리스트로 옮기기 **/
			List<MemberBeans> list = new ArrayList<MemberBeans>(); //뿌려질리스트(startRowNum 부터 endRowNum 까지
			
			for(int i = 0; i < realMemberBeansList.size(); i++){
				
				MemberBeans memberBeans = realMemberBeansList.get(i);

				//Num은 0이 아니라 1부터 시작이라 i+1
				if(adminListBeans.getStartRowNum() <= i+1 && i+1 <= adminListBeans.getEndRowNum()){
					list.add(memberBeans);
				}
			}
			
			/** 미완성된 AdminListBeans 에다가 뿌려질 리스트 값 넣기 및 Model 에 싣기 **/
			adminListBeans.setList(list);
			adminListBeans.setTotalListCount(realMemberBeansList.size()); //DB에 들어있는 전체 사이즈를 저장시키는 거임
			
			System.out.println("getStartPageNo:"+ adminListBeans.getStartPageNo());
			System.out.println("getEndPageNo:"+ adminListBeans.getEndPageNo());
			System.out.println("getStartRowNum:"+ adminListBeans.getStartRowNum());
			System.out.println("getEndRowNum:"+ adminListBeans.getEndRowNum());
			System.out.println("getSelectPageNo:"+ adminListBeans.getSelectPageNo());
			System.out.println("getPreGroupStartPageNo:"+ adminListBeans.getPreGroupStartPageNo());
			System.out.println("getNextGroupStartPageNo:"+ adminListBeans.getNextGroupStartPageNo());
			System.out.println("isShowPreviousGroup:"+ adminListBeans.isShowPreviousGroup());
			System.out.println("isShowNextGroup:"+ adminListBeans.isShowNextGroup());
			
			System.out.println("뿌려질 리스트 수 : " + adminListBeans.getList().size());
						
			return adminListBeans;
		}
		catch(Exception e){
			System.out.println("getajaxadminmember HttpServlet Exception");
			return null;
		}
	}

	/** 관리자 - 멤버페이지에서 등급수정 **/
	@RequestMapping("/setgrademodify")
	public void setGradeModify(@RequestParam("memberNo") int memberNo, @RequestParam("memberGrade") int memberGrade){
		
		System.out.println("△setgrademodify요청△");
		
		try{
			MemberBeans temp = new MemberBeans();
			temp.setMember_no(memberNo); //memberService에서 member_no 으로 검색함
			MemberBeans memberBeans = memberService.getMember(temp); //jsp에서 javascript:grade_modify(스트링인자) 가 안넘어가서 이렇게 함
			memberBeans.setMember_grade(memberGrade);
			
			
			//getMember 할때 null값은 null로 가져와서 어쩔수없이 작업해줌....
			if(memberBeans.getMember_phone()==null){
				memberBeans.setMember_phone("");
			}
			if(memberBeans.getMember_email()==null){
				memberBeans.setMember_email("");
			}
			if(memberBeans.getMember_nickname()==null){
				memberBeans.setMember_nickname("");
			}
			if(memberBeans.getMember_status()==null){
				memberBeans.setMember_status("");
			}
			
			memberService.updateMember(memberBeans);
		}
		catch(Exception e){
			System.out.println("setgrademodify HttpServlet Exception");
		}
	}
	
	/** 관리자 - 멤버페이지에서 멤버삭제 **/
	@RequestMapping("/deletemember")
	public void deleteMember(@RequestParam("memberNo") int memberNo){
		
		System.out.println("△deletemember요청△");
		
		try{
			MemberBeans temp = new MemberBeans();
			temp.setMember_no(memberNo); //memberService에서 member_no 으로 검색함
			memberService.deleteMember(temp);
		}
		catch(Exception e){
			System.out.println("deletemember HttpServlet Exception");
		}
	}

		
	
	
	/*********** CATEGORY ************/
	
	@RequestMapping("/admincategory")
	public String adminCategory(HttpSession session){
		
		/****** 관리자아이디(grade=0) 검사 아니면 main으로 가게됨 ******/ 
		try{
			String sid = String.valueOf(session.getAttribute("sid"));//마스터아이디인지 검사하려고
			MemberBeans memberBeans = memberService.getMemberById(sid);
			if(memberBeans.getMember_grade()!=0){
				return "redirect:/";
			}
		}
		catch(Exception e){
			System.out.println("adminmember Admin아이디 검색중 Exception");
			return null;
		}
		/*******************************************************/
		
		System.out.println("△admincategory요청△");
		
		return "admin/admin_category";
	}
	
	
	/** 관리자 - 카테고리페이지에서 카테고리리스트 콜백 **/
	@RequestMapping("/getajaxadmincategory")
	public @ResponseBody AdminListBeans getAjaxAdminCategory(@RequestParam("selectPageNo") int selectPageNo){
		
		System.out.println("△getajaxadmincategory요청△");
		
		
		try{

			List<CategoryBeans> realCategoryBeansList = categoryService.getCategoryAll(); //전체카테고리리스트

			/** 페이지 설정(한페이지에 보여질행수, 한페이지에 보여질페이지수 및 선택된 페이지) **/
			final int rowCount = 9; //보여질행수
			final int pagingCount = 10; //보여질페이지수
			AdminPageConfigBeans adminPageConfigBeans = new AdminPageConfigBeans(rowCount, pagingCount, selectPageNo);
			AdminListBeans adminListBeans = AdminPageCounter.instance().findList(adminPageConfigBeans, realCategoryBeansList.size()); //아직 뿌려질리스트 넣지 않은 상태
			
			/** 실제리스트에서 뽑아서 뿌려질리스트로 옮기기 **/
			List<CategoryBeans> list = new ArrayList<CategoryBeans>(); //뿌려질리스트(startRowNum 부터 endRowNum 까지
			
			for(int i = 0; i < realCategoryBeansList.size(); i++){
				
				CategoryBeans categoryBeans = realCategoryBeansList.get(i);

				//Num은 0이 아니라 1부터 시작이라 i+1
				if(adminListBeans.getStartRowNum() <= i+1 && i+1 <= adminListBeans.getEndRowNum()){
					list.add(categoryBeans);
				}
			}
			
			/** 미완성된 AdminListBeans 에다가 뿌려질 리스트 값 넣기 및 Model 에 싣기 **/
			adminListBeans.setList(list);
			adminListBeans.setTotalListCount(realCategoryBeansList.size()); //DB에 들어있는 전체 사이즈를 저장시키는 거임
			
			System.out.println("getStartPageNo:"+ adminListBeans.getStartPageNo());
			System.out.println("getEndPageNo:"+ adminListBeans.getEndPageNo());
			System.out.println("getStartRowNum:"+ adminListBeans.getStartRowNum());
			System.out.println("getEndRowNum:"+ adminListBeans.getEndRowNum());
			System.out.println("getSelectPageNo:"+ adminListBeans.getSelectPageNo());
			System.out.println("getPreGroupStartPageNo:"+ adminListBeans.getPreGroupStartPageNo());
			System.out.println("getNextGroupStartPageNo:"+ adminListBeans.getNextGroupStartPageNo());
			System.out.println("isShowPreviousGroup:"+ adminListBeans.isShowPreviousGroup());
			System.out.println("isShowNextGroup:"+ adminListBeans.isShowNextGroup());
			
			System.out.println("뿌려질 리스트 수 : " + adminListBeans.getList().size());
						
			return adminListBeans;
		}
		catch(Exception e){
			System.out.println("getajaxadmincategory HttpServlet Exception");
			return null;
		}
	}
	
	/** 관리자 - 카테고리페이지에서 카테고리명수정 **/
	@RequestMapping("/setcategorynamemodify")
	public void setCategoryNameModify(@RequestParam("categoryNo") int category_no, @RequestParam("categoryName") String category_name){
		
		System.out.println("△setcategorynamemodify요청△");

		try{
			CategoryBeans categoryBeans = categoryService.getCategory(category_no); //jsp에서 javascript:grade_modify(스트링인자) 가 안넘어가서 이렇게 함
			categoryBeans.setCategory_name(category_name);
			
			
			//getCategory_name 할때 null값은 null로 가져와서 어쩔수없이 작업해줌....
			if(categoryBeans.getCategory_name()==null){
				categoryBeans.setCategory_name("");
			}
			
			categoryService.updateCategory(categoryBeans);
		}
		catch(Exception e){
			System.out.println("setcategorynamemodify HttpServlet Exception");
		}
	}
	
	/** 관리자 - 카테고리페이지에서 카테고리명추가 **/
	@RequestMapping("/setcategorynameadd")
	public void setCategoryNameAdd(@RequestParam("categoryName") String category_name){
		
		System.out.println("△setcategorynameadd요청△");
		
		try{
			CategoryBeans categoryBeans = new CategoryBeans(0, category_name);
			
			//getCategory_name 할때 null값은 null로 가져와서 어쩔수없이 작업해줌....
			if(categoryBeans.getCategory_name()==null){
				categoryBeans.setCategory_name("");
			}
			
			categoryService.createCategory(categoryBeans);
		}
		catch(Exception e){
			System.out.println("setcategorynamemodify HttpServlet Exception");
		}
	}
	
	/** 관리자 - 카테고리페이지에서 카테고리명삭제 **/
	@RequestMapping("/deletecategory")
	public void deleteCategory(@RequestParam("categoryNo") int category_no){
		
		System.out.println("△deletecategory요청△");
		
		try{			
			categoryService.deleteCategory(category_no);
		}
		catch(Exception e){
			System.out.println("deletecategory HttpServlet Exception");
		}
	}

	

	
	/*********** COMPANY ************/
	
	@RequestMapping("/admincompany")
	public String adminCompany(HttpSession session){
		
		/****** 관리자아이디(grade=0) 검사 아니면 main으로 가게됨 ******/ 
		try{
			String sid = String.valueOf(session.getAttribute("sid"));//마스터아이디인지 검사하려고
			MemberBeans memberBeans = memberService.getMemberById(sid);
			if(memberBeans.getMember_grade()!=0){
				return "redirect:/";
			}
		}
		catch(Exception e){
			System.out.println("adminmember Admin아이디 검색중 Exception");
			return null;
		}
		/*******************************************************/
		
		System.out.println("△admincompany요청△");
		
		return "admin/admin_company";
	}
	
	/** 관리자 - 제조사페이지에서 제조사리스트 콜백 **/
	@RequestMapping("/getajaxadmincompany")
	public @ResponseBody AdminListBeans getAjaxAdminCompany(@RequestParam("selectPageNo") int selectPageNo){
		
		System.out.println("△getajaxadmincompany요청△");
		
		
		try{

			List<CompanyBeans> realComponyBeansList = companyService.getAllCompany(); //전체제조사가져오기

			/** 페이지 설정(한페이지에 보여질행수, 한페이지에 보여질페이지수 및 선택된 페이지) **/
			final int rowCount = 9; //보여질행수
			final int pagingCount = 10; //보여질페이지수
			AdminPageConfigBeans adminPageConfigBeans = new AdminPageConfigBeans(rowCount, pagingCount, selectPageNo);
			AdminListBeans adminListBeans = AdminPageCounter.instance().findList(adminPageConfigBeans, realComponyBeansList.size()); //아직 뿌려질리스트 넣지 않은 상태
			
			/** 실제리스트에서 뽑아서 뿌려질리스트로 옮기기 **/
			List<CompanyBeans> list = new ArrayList<CompanyBeans>(); //뿌려질리스트(startRowNum 부터 endRowNum 까지
			
			for(int i = 0; i < realComponyBeansList.size(); i++){
				
				CompanyBeans companyBeans = realComponyBeansList.get(i);

				//Num은 0이 아니라 1부터 시작이라 i+1
				if(adminListBeans.getStartRowNum() <= i+1 && i+1 <= adminListBeans.getEndRowNum()){
					list.add(companyBeans);
				}
			}
			
			/** 미완성된 AdminListBeans 에다가 뿌려질 리스트 값 넣기 및 Model 에 싣기 **/
			adminListBeans.setList(list);
			adminListBeans.setTotalListCount(realComponyBeansList.size()); //DB에 들어있는 전체 사이즈를 저장시키는 거임
			
			System.out.println("getStartPageNo:"+ adminListBeans.getStartPageNo());
			System.out.println("getEndPageNo:"+ adminListBeans.getEndPageNo());
			System.out.println("getStartRowNum:"+ adminListBeans.getStartRowNum());
			System.out.println("getEndRowNum:"+ adminListBeans.getEndRowNum());
			System.out.println("getSelectPageNo:"+ adminListBeans.getSelectPageNo());
			System.out.println("getPreGroupStartPageNo:"+ adminListBeans.getPreGroupStartPageNo());
			System.out.println("getNextGroupStartPageNo:"+ adminListBeans.getNextGroupStartPageNo());
			System.out.println("isShowPreviousGroup:"+ adminListBeans.isShowPreviousGroup());
			System.out.println("isShowNextGroup:"+ adminListBeans.isShowNextGroup());
			
			System.out.println("뿌려질 리스트 수 : " + adminListBeans.getList().size());
						
			return adminListBeans;
		}
		catch(Exception e){
			System.out.println("getajaxadmincompany HttpServlet Exception");
			return null;
		}
	}
	
	/** 관리자 - 제조사페이지에서 제조사명수정 **/
	@RequestMapping("/setcompanynamemodify")
	public void setCompanyNameModify(@RequestParam("companyNo") int company_no, @RequestParam("companyName") String company_name){
		
		System.out.println("△setcompanynamemodify요청△");

		try{
			CompanyBeans companyBeans = companyService.getCompanyByNo(company_no); //jsp에서 javascript:grade_modify(스트링인자) 가 안넘어가서 이렇게 함
			companyBeans.setCompany_name(company_name);
			
			
			//getCategory_name 할때 null값은 null로 가져와서 어쩔수없이 작업해줌....
			if(companyBeans.getCompany_name()==null){
				companyBeans.setCompany_name("");
			}
			
			companyService.updateCompany(companyBeans);
		}
		catch(Exception e){
			System.out.println("setcompanynamemodify HttpServlet Exception");
		}
	}
	
	/** 관리자 - 제조사페이지에서 제조사명추가 **/
	@RequestMapping("/setcompanynameadd")
	public void setCompanyNameAdd(@RequestParam("companyName") String company_name){
		
		System.out.println("△setcompanynameadd요청△");
		
		try{
			CompanyBeans companyBeans = new CompanyBeans(0, company_name);
			
			//getCategory_name 할때 null값은 null로 가져와서 어쩔수없이 작업해줌....
			if(companyBeans.getCompany_name()==null){
				companyBeans.setCompany_name("");
			}
			
			companyService.createCompany(companyBeans);
		}
		catch(Exception e){
			System.out.println("setcompanynameadd HttpServlet Exception");
		}
	}
	
	/** 관리자 - 제조사페이지에서 제조사명삭제 **/
	@RequestMapping("/deletecompany")
	public void deleteCompany(@RequestParam("companyNo") int company_no){
		
		System.out.println("△deletecompany요청△");
		
		try{			
			companyService.deleteCompany(company_no);
		}
		catch(Exception e){
			System.out.println("deletecompany HttpServlet Exception");
		}
	}
	
	
	
	
	/*********** BOARD ************/
	
	@RequestMapping("/adminboardtype")
	public String adminBoardType(HttpSession session){
		
		/****** 관리자아이디(grade=0) 검사 아니면 main으로 가게됨 ******/ 
		try{
			String sid = String.valueOf(session.getAttribute("sid"));//마스터아이디인지 검사하려고
			MemberBeans memberBeans = memberService.getMemberById(sid);
			if(memberBeans.getMember_grade()!=0){
				return "redirect:/";
			}
		}
		catch(Exception e){
			System.out.println("adminmember Admin아이디 검색중 Exception");
			return null;
		}
		/*******************************************************/
		
		System.out.println("△adminboardtype요청△");
		
		return "admin/admin_boardtype";
	}
	
	/** 관리자 - 보드카테고리페이지에서 보드카테고리리스트 콜백 **/
	@RequestMapping("/getajaxadminboardtype")
	public @ResponseBody AdminListBeans getAjaxAdminBoardType(@RequestParam("selectPageNo") int selectPageNo){
		
		System.out.println("△getajaxadminboardtype요청△");
		
		
		try{

			List<BoardTypeBeans> realboardTypeBeansList = boardTypeService.getAllBoardType(); //전체보드타입가져오기

			/** 페이지 설정(한페이지에 보여질행수, 한페이지에 보여질페이지수 및 선택된 페이지) **/
			final int rowCount = 9; //보여질행수
			final int pagingCount = 10; //보여질페이지수
			AdminPageConfigBeans adminPageConfigBeans = new AdminPageConfigBeans(rowCount, pagingCount, selectPageNo);
			AdminListBeans adminListBeans = AdminPageCounter.instance().findList(adminPageConfigBeans, realboardTypeBeansList.size()); //아직 뿌려질리스트 넣지 않은 상태
			
			/** 실제리스트에서 뽑아서 뿌려질리스트로 옮기기 **/
			List<BoardTypeBeans> list = new ArrayList<BoardTypeBeans>(); //뿌려질리스트(startRowNum 부터 endRowNum 까지
			
			for(int i = 0; i < realboardTypeBeansList.size(); i++){
				
				BoardTypeBeans boardTypeBeans = realboardTypeBeansList.get(i);

				//Num은 0이 아니라 1부터 시작이라 i+1
				if(adminListBeans.getStartRowNum() <= i+1 && i+1 <= adminListBeans.getEndRowNum()){
					list.add(boardTypeBeans);
				}
			}
			
			/** 미완성된 AdminListBeans 에다가 뿌려질 리스트 값 넣기 및 Model 에 싣기 **/
			adminListBeans.setList(list);
			adminListBeans.setTotalListCount(realboardTypeBeansList.size()); //DB에 들어있는 전체 사이즈를 저장시키는 거임
			
			System.out.println("getStartPageNo:"+ adminListBeans.getStartPageNo());
			System.out.println("getEndPageNo:"+ adminListBeans.getEndPageNo());
			System.out.println("getStartRowNum:"+ adminListBeans.getStartRowNum());
			System.out.println("getEndRowNum:"+ adminListBeans.getEndRowNum());
			System.out.println("getSelectPageNo:"+ adminListBeans.getSelectPageNo());
			System.out.println("getPreGroupStartPageNo:"+ adminListBeans.getPreGroupStartPageNo());
			System.out.println("getNextGroupStartPageNo:"+ adminListBeans.getNextGroupStartPageNo());
			System.out.println("isShowPreviousGroup:"+ adminListBeans.isShowPreviousGroup());
			System.out.println("isShowNextGroup:"+ adminListBeans.isShowNextGroup());
			
			System.out.println("뿌려질 리스트 수 : " + adminListBeans.getList().size());
						
			return adminListBeans;
		}
		catch(Exception e){
			System.out.println("getajaxadminboardtype HttpServlet Exception");
			return null;
		}
	}
	
	/** 관리자 - 보드카테고리페이지에서 보드카테고리명수정 **/
	@RequestMapping("/setboardtypenamemodify")
	public void setBoardTypeNameModify(@RequestParam("boardTypeNo") int boardtype_no, @RequestParam("boardTypeName") String boardtype_name){
		
		System.out.println("△setboardtypenamemodify요청△");

		try{
			BoardTypeBeans boardTypeBeans = boardTypeService.getBoardType(boardtype_no); //jsp에서 javascript:grade_modify(스트링인자) 가 안넘어가서 이렇게 함
			boardTypeBeans.setBtype_name(boardtype_name);
			
			
			//getCategory_name 할때 null값은 null로 가져와서 어쩔수없이 작업해줌....
			if(boardTypeBeans.getBtype_name()==null){
				boardTypeBeans.setBtype_name("");
			}
			
			boardTypeService.updateBoardType(boardTypeBeans);
		}
		catch(Exception e){
			System.out.println("setboardtypenamemodify HttpServlet Exception");
		}
	}
	
	/** 관리자 - 보드카테고리페이지에서 보드카테고리명추가 **/
	@RequestMapping("/setboardtypenameadd")
	public void setBoardTypeNameAdd(@RequestParam("boardTypeName") String boardType_name){
		
		System.out.println("△setboardtypenameadd요청△");
		
		try{
			BoardTypeBeans boardTypeBeans = new BoardTypeBeans(0, boardType_name);
			
			//getCategory_name 할때 null값은 null로 가져와서 어쩔수없이 작업해줌....
			if(boardTypeBeans.getBtype_name()==null){
				boardTypeBeans.setBtype_name("");
			}
			
			boardTypeService.create(boardTypeBeans);
		}
		catch(Exception e){
			System.out.println("setboardtypenameadd HttpServlet Exception");
		}
	}
	
	/** 관리자 - 보드카테고리페이지에서 보드카테고리명삭제 **/
	@RequestMapping("/deleteboardtype")
	public void deleteBoardType(@RequestParam("boardTypeNo") int boardType_no){
		
		System.out.println("△deleteboardtype요청△");
		
		try{			
			boardTypeService.deleteBoardType(boardType_no);
		}
		catch(Exception e){
			System.out.println("deleteboardtype HttpServlet Exception");
		}
	}

	
	
	
	/*********** PRODUCT ************/	
	
	@RequestMapping("/adminproduct")
	public String adminProduct(){
		
		System.out.println("△adminproduct요청△");
		
		return "admin/admin_product";
	}
	
	
	
	

	
	
	
	
	
	
	
	
	
	
	
	
	/*
	//ajax (반환타입앞에 @ResponseBody를 선언해서 컬백 인자에 객체로 넘기는것을 알린다??)
	@RequestMapping("/getajaxmemberbeans")
	public @ResponseBody List<MemberBeans> getAjaxMemberBeans(){
		
		System.out.println("△getajaxmemberbeans요청△");
		try{
			List<MemberBeans> memberBeansList = memberService.getMemberList();
			return memberBeansList;
		}
		catch(Exception e){
			System.out.println("getajaxmemberbeans HttpServlet Exception");
			return null;
		}
	}

	//join_form
	@RequestMapping("/joinform")
	public String joinForm(HttpSession session){
		
		System.out.println("△joinform요청△");
		
		try{
			//세션이 잡혀있을 때(로그인중일때) joinform 요청한다면...
			String sid = (String)session.getAttribute("sid");
			if(sid != null){
				return "redirect:/";
			}
			return "member/join_form";
		}
		catch(Exception e){
			System.out.println("joinform HttpServlet Exception");
			return "redirect:/";
		}
		
	}

	//join_action
	@RequestMapping("/joinaction")
	public String joinAction(@ModelAttribute MemberBeans memberBeans, @RequestParam("member_yyyy") int member_yyyy,
					@RequestParam("member_mm") int member_mm,  @RequestParam("member_dd") int member_dd,
					@RequestParam("member_zipcode1") String member_zipCode1, @RequestParam("member_zipcode2") String member_zipCode2,
					HttpServletRequest request){

		System.out.println("△joinaction요청△");
		
		try{
			request.setCharacterEncoding("utf-8");
			
			final int minusyyyy = 1900; //sql.Date.class 에서 1900년을 기본으로 더하게 되있음
			Date member_birth = new Date(member_yyyy-minusyyyy, member_mm-1,member_dd);
			memberBeans.setMember_birth(member_birth);
			
			String member_zip = member_zipCode1 + "-" + member_zipCode2;
			memberBeans.setMember_zip(member_zip);
			
			memberService.createMember(memberBeans);
			
			return "redirect:loginform?result=1";
		}
		catch (Exception e){
			System.out.println("joinaction HttpServlet Exception");
			return "redirect:/";
		}

	}*/
}
